package manage.model;

import m.common.model.FieldMeta;
import m.common.model.LinkTableMeta;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryUtil;
import m.common.model.util.ModelUpdateUtil;
import m.system.cache.FlushCache;
import m.system.db.DBManager;
import m.system.db.DataRow;

@TableMeta(name="os_system_info",description="系统信息表")
public class SystemInfo extends Model implements FlushCache {
	private static final long serialVersionUID = 1L;
	@FieldMeta(name="domain_name",type=FieldType.STRING,length=200,description="域名")
	private String domainName;
	@FieldMeta(name="static_domain",type=FieldType.STRING,length=200,description="静态域名地址")
	private String staticDomain;
	@FieldMeta(name="static_mode",type=FieldType.STRING, defaultValue="N",description="静态加速模式",dictOption = "N:不加速,A:域名加速,B:主机间加速,C:全加速")
	private String staticMode;
	@FieldMeta(name="background_title",type=FieldType.STRING,length=50,description="后台标题")
	private String backgroundTitle;
	@FieldMeta(name="title_type",type=FieldType.STRING, description="后台显示类型",dictOption = "N:标题,Y:图片,A:图片+文本")
	private String titleType;
	@LinkTableMeta(name="title_icon_oid",table=IconInfo.class,description="标题图片")
	private IconInfo titleIcon;
	@FieldMeta(name="bg_type",type=FieldType.STRING, defaultValue="N",description="登录背景",dictOption = "N:不使用背景,Y:使用背景")
	private String backgroundType;
	@LinkTableMeta(name="bg_image_oid",table=ImageInfo.class,description="背景图片")
	private ImageInfo backgroundImage;
	@FieldMeta(name="assist_login",type=FieldType.STRING, defaultValue="N",description="外协登录",dictOption = "N:关闭,Y:开启")
	private String assistLogin;
	@FieldMeta(name="image_mode",type=FieldType.STRING, defaultValue="A",description="图片压缩",dictOption = "A:默认,B:普清,C:高清")
	private String imageMode;
	@FieldMeta(name="border_radius",type= FieldType.STRING,length = 10,description="边角风格",dictOption = "1:直角,3:默认,8:圆角,16:大圆角")
	private String borderRadius;
	@FieldMeta(name="form_mode",type= FieldType.STRING,length = 20,description="Form风格",defaultValue = "NORMAL",dictOption = "NORMAL:普通模式,ROW:行模式,DESC:描述模式")
	private String formMode;
	@FieldMeta(name="primary_color",type= FieldType.STRING,length=20,description="主题色")
	private String primaryColor;
	@FieldMeta(name="success_color",type= FieldType.STRING,length=20,description="成功色")
	private String successColor;
	@FieldMeta(name="warning_color",type= FieldType.STRING,length=20,description="警戒色")
	private String warningColor;
	@FieldMeta(name="error_color",type= FieldType.STRING,length=20,description="错误色")
	private String errorColor;
	@FieldMeta(name="info_color",type= FieldType.STRING,length=20,description="信息色")
	private String infoColor;

	public String getFormMode() {
		return formMode;
	}

	public void setFormMode(String formMode) {
		this.formMode = formMode;
	}

	public String getSuccessColor() {
		return successColor;
	}

	public void setSuccessColor(String successColor) {
		this.successColor = successColor;
	}

	public String getWarningColor() {
		return warningColor;
	}

	public void setWarningColor(String warningColor) {
		this.warningColor = warningColor;
	}

	public String getErrorColor() {
		return errorColor;
	}

	public void setErrorColor(String errorColor) {
		this.errorColor = errorColor;
	}

	public String getInfoColor() {
		return infoColor;
	}

	public void setInfoColor(String infoColor) {
		this.infoColor = infoColor;
	}

	public String getBorderRadius() {
		return borderRadius;
	}

	public void setBorderRadius(String borderRadius) {
		this.borderRadius = borderRadius;
	}

	public String getPrimaryColor() {
		return primaryColor;
	}

	public void setPrimaryColor(String primaryColor) {
		this.primaryColor = primaryColor;
	}

	public String getDomainName() {
		return domainName;
	}
	public void setDomainName(String domainName) {
		this.domainName = domainName;
	}
	public String getStaticDomain() {
		return staticDomain;
	}
	public void setStaticDomain(String staticDomain) {
		this.staticDomain = staticDomain;
	}
	public String getStaticMode() {
		return staticMode;
	}
	public void setStaticMode(String staticMode) {
		this.staticMode = staticMode;
	}
	public String getBackgroundTitle() {
		return backgroundTitle;
	}
	public void setBackgroundTitle(String backgroundTitle) {
		this.backgroundTitle = backgroundTitle;
	}
	public String getTitleType() {
		return titleType;
	}
	public void setTitleType(String titleType) {
		this.titleType = titleType;
	}
	public IconInfo getTitleIcon() {
		return titleIcon;
	}
	public void setTitleIcon(IconInfo titleIcon) {
		this.titleIcon = titleIcon;
	}
	public String getBackgroundType() {
		return backgroundType;
	}
	public void setBackgroundType(String backgroundType) {
		this.backgroundType = backgroundType;
	}
	public ImageInfo getBackgroundImage() {
		return backgroundImage;
	}
	public void setBackgroundImage(ImageInfo backgroundImage) {
		this.backgroundImage = backgroundImage;
	}

	public String getAssistLogin() {
		return assistLogin;
	}

	public void setAssistLogin(String assistLogin) {
		this.assistLogin = assistLogin;
	}

	public String getImageMode() {
		return imageMode;
	}

	public void setImageMode(String imageMode) {
		this.imageMode = imageMode;
	}

	@Override
	public SystemInfo getCacheModel(String key) throws Exception {
		DataRow dr= DBManager.queryFirstRow("SELECT oid FROM os_system_info");
		SystemInfo ps=new SystemInfo();
		if(null==dr){
			ps.setOid("1");
			ps.setTitleType("N");
			ps.setBackgroundTitle("后台管理");
			ps.setDomainName("");
			ps.setStaticDomain("");
			ps.setStaticMode("N");
			ps.setAssistLogin("N");
			ps.setImageMode("A");
			ps.setBackgroundImage(new ImageInfo());
			ps.setTitleIcon(new IconInfo());
			ps.setBorderRadius("3");
			ModelUpdateUtil.insertModel(ps);
		}else{
			ps.setOid(dr.get(String.class,"oid"));
		}
		return ModelQueryUtil.getModel(ps,1);
	}
}
